package com.jt.controller;

import com.jt.pojo.ItemDesc;
import com.jt.util.ObjectMapperUtil;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class JSONPController {
    @RequestMapping("/web/testJSONP")
    @CrossOrigin //允许跨域访问
    public String jsonp(String callback){
        ItemDesc itemDesc=new ItemDesc();
        itemDesc.setItemId(100L).setItemDesc("desc你好");
        String json = ObjectMapperUtil.toJSON(itemDesc);
        return callback+"("+json+")";
    }

}
